//
//  BehaviorRelay+RangeReplaceableCollection.swift
//  Trill
//
//  Created by 顾钱想 on 2019/11/10.
//  Copyright © 2019 顾钱想. All rights reserved.
//


import RxCocoa

public extension BehaviorRelay where Element: RangeReplaceableCollection {

    var append: AnyObserver<Element> {

        return AnyObserver { [weak self] event in

            guard let self = self else { return }

            switch event {
            case .next(let data):
                self.accept(self.value + data)
            case .error(let error):
                print("Data Task Error: \(error)")
            default:
                break
            }
        }
    }
}
